﻿using System.IO;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;

namespace Weather.com.Client.Test.SupportedServiceSchema
{
    public class SupportedServiceSchemaTestBase : TestBase
    {
        protected Stream GetEmbeddedResouce(string resourceName)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();
            Stream resourceStream = assembly.GetManifestResourceStream(assembly.GetName().Name + "." + resourceName);
            return resourceStream;
        }

        protected void ValidateXmlWithXsd(string xml, Stream xsd)
        {
            using (XmlValidatingReader xmlReader = new XmlValidatingReader(new XmlTextReader(new StringReader(xml))))
            {
                XmlSchema xmlSchema = XmlSchema.Read(new XmlTextReader(xsd), null);
                xmlReader.Schemas.Add(xmlSchema);
                while (xmlReader.Read())
                { }
            }
        }
    }
}